module Piston
  class ProjectItemViewModel
    include Piston::ViewModelBase
    include System::Collections::ObjectModel

    declare_event :PropertyChanged
    attr_accessor :children

    def initialize(person, parent = nil)
      @person = person
      @parent = parent

      list = System::Collections::Generic::List[ProjectItemViewModel].new

      @person.children.each do |child|
        vm = ProjectItemViewModel.new(child, self)
        list.add vm
      end

      @children = ReadOnlyCollection[ProjectItemViewModel].new(list)
      
    end

    def name
      @person.name
    end
  end
end